import json
from peft import LoraConfig, TaskType

# 从 JSON 文件读取配置
def load_lo_conf(json_path):
    with open(json_path, "r") as f:
        config = json.load(f)
    
    # 将 JSON 中的配置转换为 LoraConfig 对象
    lo_conf = LoraConfig(
        r=config["r"],
        target_modules=config["target_modules"],
        task_type=TaskType[config["task_type"]],  # 将字符串映射为 TaskType 枚举
        lora_alpha=config["lora_alpha"],
        lora_dropout=config["lora_dropout"]
    )
    return lo_conf

# 使用示例
#TODO
lora_conf_pa = "./lora_conf.json"
lo_conf = load_lo_conf(lora_conf_pa)